
package xj.graph2d.util;

import java.util.*;

import xj.graph2d.DrawShape;

public class DrawShapeTreeNode { 

  public DrawShapeTreeNode getParent() { 
    return parent; 
  }

  public void setParent(DrawShapeTreeNode parent) { 
    this.parent = parent; 
  }

  public DrawShapeList getShapes() { 
    return shapes; 
  }

  public void setShapes(DrawShapeList shapes) {
    this.shapes = shapes; 
  }

  public void addNode(DrawShapeTreeNode node) { 
    if (node != null) { 
      if (children == null) { 
	children = new ArrayList<DrawShapeTreeNode>();
      }
      children.add(node);
    }
  }

  public void removeNode(DrawShapeTreeNode node) { 
    if (node != null && children != null) { 
      children.remove(node);
    }
  }

  public int nodeCount() { 
    if (children != null) { 
      return children.size(); 
    }
    return 0;
  }

  public boolean isRoot() { 
    return (parent == null);
  }

  public boolean isLeaf() { 
    return children == null;
  }

  protected DrawShapeTreeNode parent; 
  protected List<DrawShapeTreeNode> children; 
  
  protected DrawShapeList shapes; 

}